#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=2e5+1000;
typedef long long LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
deque<LL>que;
LL a[maxn];
struct P{
   LL fi,se;
}ans1[maxn*2],ans2[maxn*2];
LL tot1=0,tot2=0;
int main(void){
   cin.tie(0);std::ios::sync_with_stdio(false);
   LL n,q;cin>>n>>q;
   LL mx=-1;LL pos=0;
   for(LL i=1;i<=n;i++) {
       cin>>a[i];
       que.push_back(a[i]);
       if(mx<a[i]){
          mx=a[i];pos=i;
       }
   }
   for(LL i=1;i<=2*n;i++){
       LL one=que.front();que.pop_front();
       LL two=que.front();que.pop_front();
       ans1[++tot1].fi=one;
       ans1[tot1].se=two;
       if(one==mx){
          ans2[++tot2].fi=one;
          ans2[tot2].se=two;
       }
       if(one>two){
          que.push_front(one);
          que.push_back(two);
       }
       else{
          que.push_front(two);
          que.push_back(one);
       }
   }
   ///debug(tot1);
   ///debug(tot2);
   while(q--){
      LL m;cin>>m;
      if(m<=pos){
         cout<<ans1[m].fi<<" "<<ans1[m].se<<"\n";
      }
      else{
         LL cnt=m-pos;
     ///    debug(cnt);
         LL mod=cnt%(n-1)+1;
     ///    debug(mod);
         cout<<ans2[mod].fi<<" "<<ans2[mod].se<<"\n";
      }
   }
   return 0;
}
